package com.hspedu.newData.力扣周赛.周赛.第450;

import org.junit.Test;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-05-18 
 * @Version: 1.0
 */

public class Q1数位和等于下标的最小下标 {

    public int smallestIndex(int[] nums) {

        for (int i = 0; i < nums.length; i++) {

            if (check(nums[i],i)){
                return i;
            }
        }
        return -1;
    }

    public boolean check(int i,int j){

        int sum = 0;
        while (i>0){
            sum += i%10;
            i /= 10;
        }
        return sum == j;
    }

    @Test
    public void test() {
        // 测试代码

        int i = smallestIndex(new int[]{1, 3, 2});
        int j = smallestIndex(new int[]{1,10,11});
        int l = smallestIndex(new int[]{1,2,3});
        System.out.println("111");
    }
}
